// axios 统一操作
import XJHRequest from './request';
import config from './request/config';
const { BASE_URL, TIME_OUT } = config;
import localCache from '@/utils/cache';
const xjhRequest = new XJHRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  showLoading: false,
  interceptors: {
    requestInterceptor: (config) => {
      // token处理
      let token = localCache.getCache('token');
      if (token) {
        config.headers
          ? (config.headers.Authorization = `Bearer ${token}`)
          : (token = '');
      }
      return config;
    },
    responseInterceptor: (config) => {
      return config;
    }
  }
});

export default xjhRequest;
